import com.atcjx.BackpartApplication;
import com.atcjx.mapper.ArticleMapper;
import com.atcjx.pojo.Article.Article;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @author admin
 * @version 1.0.0
 * @ClassName test.java
 * @Description TODO
 * @createTime 2022年03月26日 21:45:00
 */
@SpringBootTest(classes = BackpartApplication.class,webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
public class test {
    @Autowired
    ArticleMapper articleMapper;

    private String preUrl = "https://gitee.com/Cjx_723/my-pic-warehouse/raw/master";
    private String url = "https://pic-1307682369.cos.ap-beijing.myqcloud.com/picGo";
    @Test
    public void changeMdFile() {
        List<Article> articlesByCondition = articleMapper.getArticlesByCondition(null);
        for (Article article : articlesByCondition) {
            String str = article.getContent();
            article.setContent(str.replaceAll(preUrl, url));
            articleMapper.updateById(article);
        }
    }
    @Test
    public void test1(){
        String str = preUrl + "/1231234123412341234.png";
        str.replaceAll(preUrl, url);
        System.out.println(str);
    }

}
